package com.osfw.activiti.enums;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 流程节点执行结果
 */
public enum ProcExecResult {
    NODE_EXECUTION(1, "节点执行中"), // 节点审批未完成，更新当前执行
    PROCESS_EXECUTION(2, "流程执行中"), //节点审批已完成，流转至下个节点
    NODE_ENDED(3, "节点已结束"),
    PROCESS_ENDED(4, "流程已结束"); //节点审批已结束，审批流已结束

    private Integer result;
    private String name;

    ProcExecResult(Integer result, String name) {
        this.result = result;
        this.name = name;
    }

    public Integer getResult() {
        return result;
    }

    public String getName() {
        return name;
    }


    public static ProcExecResult getProcExecResult(Integer result) {
        for (ProcExecResult resultEnum : values()) {
            if (resultEnum.getResult().intValue() == result.intValue()) {
                return resultEnum;
            }
        }
        return null;
    }

    public static Map<Integer, String> getProcExecResultList() {
        HashMap<Integer, String> map = new LinkedHashMap<>();
        for (ProcExecResult resultEnum : values()) {
            map.put(resultEnum.getResult(), resultEnum.getName());
        }
        return map;
    }


}
